// 移动设备中  是否存在某个文件
export function HasEcgFile(fileName){
  return new Promise(function (resolve,reject) {
    window.HasEcgFile(fileName,function (result) {
      if(result){
        resolve(result);
      }else{
        reject("HasEcgFile error");
      }
    });
  });
}

// 获得浏览器版本
export function getVersion(){
  return new Promise(function (resolve,reject) {
    window.getVersion(function (result) {
      if(result){
        resolve(result);
      }else{
        reject("getVersion error");
      }
    });
  });
}
// 更新浏览器版本 BeginUpdate
export function BeginUpdate(version,url){
  return new Promise(function (resolve,reject) {
    window.BeginUpdate(version,url,function (result) {
      if(result){
        resolve(result);
      }else{
        reject("BeginUpdate error");
      }
    });
  });
}

// 清理目录
export function DeleteFiles(dirName){
  return new Promise(function (resolve,reject) {
    window.DeleteFiles(dirName,function (result) {
      if(result){
        resolve(result);
      }else{
        reject("DeleteFiles error");
      }
    });
  });
}

// 下载文件
export function DownloadToFile(xmlPath, saveDirector, fileName, isAsync){
  return new Promise(function (resolve,reject) {
    window.DownloadToFile(xmlPath, saveDirector, fileName, isAsync,function (result) {
      if(result){
        resolve(result);
      }else{
        reject("DownloadToFile error");
      }
    });
  });
}
// 调用心电分析软件
export function DockerAnalyze(saveDirector, isAsync){
  return new Promise(function (resolve,reject) {
    window.DockerAnalyze(saveDirector, function (result) {
      if(result){
        resolve(result);
      }else{
        reject("DockerAnalyze error");
      }
    });
  });
}
// 文件上传
/**
 *
 * @param url 上传地址
 * @param saveDirector 读取目录
 * @param naturalKey 检查id
 * @param isAsync 是否异步 1 异步 0 同步
 * @param token 令牌
 * @returns {Promise<unknown>}
 * @constructor
 */
export function HttpUploadEcg(url,saveDirector,naturalKey, isAsync, token){
  return new Promise(function (resolve,reject) {
    window.HttpUploadEcg(url, saveDirector, naturalKey, isAsync, token, function (result) {
      if(result){
        resolve(result);
      }else{
        reject("DockerAnalyze error");
      }
    });
  });
}

// 删除指定文件

export function DeleteFile(fileName, isAsync){
  return new Promise(function (resolve,reject) {
    window.DeleteFile(fileName, function (result) {
      if(result){
        resolve(result);
      }else{
        reject("DeleteFile error");
      }
    });
  });
}



// 获得操作系统版本
export function getOsVersion(){
  return new Promise(function (resolve,reject) {
    window.getOsVersion(function (result) {
      if(result){
        resolve(result);
      }else{
        reject("getOsVersion error");
      }
    });
  });
}
